# vFabric Administration Server Ruby API
# Copyright (c) 2012 VMware, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


module Gemfire

  class TestLiveApplicationCode < VasTestCase

    def test_list
      application_code = LiveApplicationCodes.new(
          'https://localhost:8443/gemfire/v1/groups/1/cache-server-instances/2/application-code/live/',
          StubClient.new)
      assert_count(2, application_code)
      assert_equal('https://localhost:8443/vfabric/v1/security/4/', application_code.security.location)
    end
  
    def test_live_application_code
      location = 'https://localhost:8443/gemfire/v1/groups/1/cache-server-instances/2/application-code/live/3/'
  
      live_application_code = ApplicationCode.new(location, StubClient.new)

      assert_equal('example', live_application_code.name)
      assert_equal('1.0.0', live_application_code.version)

      assert_equal('https://localhost:8443/gemfire/v1/groups/1/cache-server-instances/2/', live_application_code.instance.location)
      assert_equal('https://localhost:8443/vfabric/v1/security/4/', live_application_code.security.location)
      assert_equal('https://localhost:8443/gemfire/v1/groups/1/cache-server-instances/2/application-code/live/3/', live_application_code.location)
    end
  
  end
end
